<template>
  <div>
    <el-card style="margin: 8px">
      <el-row>
        <h1>上海数据分中心固定资产详情</h1>
      </el-row>
      <el-row>
        <el-col :span="12" >
          <span class="notes">分中心固定资产编号：</span> {{form.assetTagNumber}}
        </el-col>
        <el-col :span="12" style="text-align: right">
          <el-button :size="size" type="info" icon="el-icon-printer" v-print="printObj">打印</el-button>
          <!-- <el-button :size="size">导出</el-button> -->
          <el-button icon="el-icon-back" @click="returnGo" :size="size">返回</el-button>
        </el-col>
      </el-row>
    </el-card>
    <el-card style="margin: 8px">
      <!-- 固定资产详情 -->
      <AssetsInfo ref="AssetsInfo" id="printMe"></AssetsInfo>
      <el-tabs stretch style="margin: 8px">
        <el-tab-pane label="调拨申请">

          <el-skeleton v-if="processLoading" :rows="6" animated />
          <el-empty v-if="!processLoading && moveList.length === 0" description="暂无流程"></el-empty>

          <div v-for="(item,index) in moveList" :key="index" class="tips">
            <el-row >
              <el-col :span="8"><strong>调拨申请时间：</strong>{{ item.startTime }}</el-col>
              <el-col :span="8"><strong>当前状态：</strong>{{ item.currentNode }}</el-col>
              <el-col :span="5"><strong>申请人员：</strong>{{ item.startUserName }}</el-col>
              <el-col :span="3">
                <el-button @click="showProcess(item)" type="primary">查看详情</el-button>
              </el-col>
            </el-row>
          </div>

        </el-tab-pane>
        <el-tab-pane label="报废申请">
          <el-empty v-if="!processLoading && invalidList.length === 0" description="暂无流程"></el-empty>

          <div v-for="(item,index) in invalidList" :key="index" class="tips">
            <el-row >
              <el-col :span="8"><strong>报废申请时间：</strong>{{ item.startTime }}</el-col>
              <el-col :span="8"><strong>当前状态：</strong>{{ item.currentNode }}</el-col>
              <el-col :span="5"><strong>申请人员：</strong>{{ item.startUserName }}</el-col>
              <el-col :span="3">
                <el-button @click="showProcess(item)" type="primary">查看详情</el-button>
              </el-col>
            </el-row>
          </div>

        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>


<script>

  import { get,listProcess } from '@/api/bizFixAssets/bizFixAssetsApi.js'
  import AssetsInfo from "./AssetsInfo";

export default {
  components: {AssetsInfo},
  data() {
    return {
      form: {},
      size: 'mini',
      id: undefined,
      loading: true,
      processLoading: true,
      disable: true,
      moveList: [],
      invalidList: [],
       printObj: {
        id: 'printMe', // 这里是要打印元素的ID
        popTitle: '&nbsp', // 打印的标题
        extraCss: '', // 打印可引入外部的一个 css 文件
        extraHead: '' // 打印头部文字
      },
    }
  },
  mounted() {
    this.id = this.$route.query.id;
    this.init();
  },
  methods: {
    init() {
      // 查询固定资产详情
      get(this.id).then(resp => {
        this.$refs.AssetsInfo.init(resp);
        this.form = resp;
      }).finally(() => {
        this.$refs.AssetsInfo.finish();
      })
      // 查询作废，调拨流程列表
      listProcess(this.id).then(resp => {
        this.moveList = resp.moveList;
        this.invalidList = resp.invalidList;
      }).finally(() => {
        this.processLoading = false;
      })
    },
    // 查看流程详情
    showProcess(row) {
      this.$router.push({
        path: '/workflow/process/assetsprocessmanager/' + row.procInsId,
        query: {
          assetTagNumber: this.form.assetTagNumber,
          status: this.form.status,
          processed: false,
        }
      })
    },
    returnGo() {
      this.$router.back(-1)
    },
  }
}
</script>

<style lang="scss">
el-dialog {
  background: #ffffff;
  border: 1px solid #ffffff;
}
.notes {
  font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif;
  font-style: normal;
  font-weight: 650;
  font-size: 13px;
  color: #999999;
}
.tips {
  margin: 10px;
  padding: 25px;
  border-left: #24d2d3 5px solid;
  border-radius: 5px;
  box-shadow: 2px 2px 7px #ededed;

}
  .tips:hover {
    background-color: #f8f8f8;
  }

</style>
